package com.jin.spirng_boot_learn.ioc.beans;


import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Car implements BeanNameAware,InitializingBean,DisposableBean{

    // spring 容器默认调用 无参构造
    public Car() {
        System.out.println("---init---Car"+0);
    }

//    @Autowired
//    public BeanFactory beanFactory;

    @Autowired
    public Ship ship;

    public void carInitMethod() {
        System.out.println("carInitMethod beans init function"+4);
    }

    public void carDestroyMethod() {
        System.out.println("cars destory method"+7);
    }


    @Override
    public void setBeanName(String name) {
        System.out.println("aware" + name+1);

    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet"+3);
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("DisposableBean"+6);
    }

//    @Override
//    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
//        System.out.println("11111111111111111111111111111");
//    }
}
